"use strict";

// http://open.chrome.360.cn/extension_dev/contextMenus.html
var menuItemId = chrome.contextMenus.create({
    title: "查看背景图像",
    contexts: ["all"],
    documentUrlPatterns: ["http://*/*", "https://*/*"]
});
chrome.runtime.onMessage.addListener(function (request) {
    chrome.contextMenus.update(menuItemId, {
        enabled: !!request.url,
        onclick: function (info, tab) {
            request.url && chrome.tabs.create({url: request.url, index: tab.index + 1});
        }
    });
});